package com.guigu.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.ProcureService;
import com.guigu.mapper.ProcureMapper;
import com.guigu.pojo.Procure;
import com.guigu.vo.Pojo;
import com.guigu.vo.ProcureVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProcureServiceImpl extends ServiceImpl <ProcureMapper, Procure> implements ProcureService {
    @Autowired
    private  ProcureMapper procureMapper;
    @Override
    public PageInfo<Procure> selectAll1(ProcureVo vo, int pageNo, int pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<Procure> procures = procureMapper.selectAll1(vo);
        PageInfo<Procure> procurePageInfo = new PageInfo<>(procures);
        return procurePageInfo;
    }
    @Override
    public Pojo<Procure> selectAll(int pageNum, int pageSize, ProcureVo vo) {
        PageHelper.startPage(pageNum,pageSize);
        List<Procure> procureList = procureMapper.selectAll(vo);
        PageInfo<Procure> procurePageInfo = new PageInfo<>(procureList);
        Pojo<Procure> procurePojo = new Pojo<>();
        procurePojo.setRows(procurePageInfo.getList());
        procurePojo.setTotal(procurePageInfo.getTotal());
        return procurePojo;
    }

    @Override
    public String queryProcedureByMaxId() {
        Procure procure = procureMapper.selectProcureByMaxId();
        if (procure!=null)
            return procure.getProcureNumber();
        return null;
    }
}